# 简要说明
# 这个示例用来测试使用cmake进行跨平台以及交叉编译
# 如果需要指定交叉编译平台需要指定例如：-DCMAKE_SYSTEM_NAME=iOS|tvOS|watchOS|Android|Darwin|Linux

cmake_minimum_required(VERSION 3.0.0)
project(cross_compile_demo VERSION 0.1.0)

include(CTest)
enable_testing()

message(CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})

if(${CMAKE_SYSTEM_NAME} STREQUAL "")
    if(WIN32)
        set(WINDOWS 1)
    elseif(UNIX AND NOT APPLE)
        set(LINUX 1)
    else()
        set(MACOS 1)
    endif(WIN32)    
else()
    if(CMAKE_SYSTEM_NAME STREQUAL "Android")
        set(ANDROID 1)
    elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
        set(IOS 1)
    elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
        set(TVOS 1)
    elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS")
        set(WATCHOS 1)
    else()
        if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
            set(WINDOWS 1)
        elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
            set(MACOS 1)
        else()
            message(FATAL_ERROR "NOT SUPPORT SYSTEM TYPE")
        endif()
    endif()    
endif()

if(WINDOWS)
message("system type is windows")
elseif(LINUX)
message("system type is linux")
elseif(MACOS)
message("system type is macos")
elseif(ANDROID)
message("system type is android")
elseif(IOS)
message("system type is ios")
elseif(TVOS)
message("system type is tvos")
elseif(WATCHOS)
message("system type is watchos")
endif()

add_executable(cross_compile_demo main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
